﻿#include "HiUnSafeSmartHeapList.h"

#include "HiUnSafeSmartHeapListImpl.h"

HiUnSafeSmartHeapList::~HiUnSafeSmartHeapList() {
	this->Destory();
}

void HiUnSafeSmartHeapList::Destory() {
	if (this->impl) {
		delete this->impl;
		this->impl = nullptr;
	}
}

bool HiUnSafeSmartHeapList::Init(int count, const ALLOC_FUN& allocFun, const RELEASE_FUN& releaseFun) {	
	if (this->impl) {
		return false;
	}
	this->impl = new HiUnSafeSmartHeapListImpl();
	this->impl->Init(count, allocFun, releaseFun);
	return true;
}

void* HiUnSafeSmartHeapList::CreateData() {
	if (!this->impl) {
		return nullptr;
	}
	return this->impl->CreateData();
}

int HiUnSafeSmartHeapList::UsingCount() {
	if (!this->impl) {
		return 0;
	}
	return this->impl->WaterLevel();
}

void HiUnSafeSmartHeapList::Release(void* t) {
	if (!this->impl) {
		return;
	}
	return this->impl->Destory(t);
}